import { ServerConfig } from '../objects/ServerConfig';
import { createHash } from 'crypto';

export function databaseUri(config: ServerConfig) {
	return `mongodb://${config.database.host}:${config.database.port}/${config.database.database}`;
}

export function generateGlob(password: string, salt: string) {
	let hash = createHash('sha256');
	hash.update(password);
	hash.update(salt);
	return hash.digest().toString('hex')
}

export function verifySalt(password: string, salt: string, glob: string) {
	return generateGlob(password, salt) == glob;
}
